package com.cherrish.demo.spring;

import lombok.Data;
import org.springframework.beans.factory.FactoryBean;

/**
 * @author cherrish
 * @time 2019-03-19 15:21
 * @name PeopleFactoryBean
 * @desc:
 */
@Data
public class PeopleFactoryBean implements FactoryBean<People> {
    private String phoneInfo;


    @Override
    public People getObject() throws Exception {
        People people = new People();
        Phone phone = new Phone();
        String info[] = phoneInfo.split(",");
        phone.setSize(info[0]);
        phone.setName(info[1]);
        phone.setLogo(info[2]);
        people.setPhone(phone);
        people.setName(info[3]);
        return people;
    }

    @Override
    public Class<?> getObjectType() {
        return Phone.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
